package com.hyh.main.weatherdata;

import java.util.ArrayList;
import java.util.List;

import com.hyh.main.display.Observer;

public class WeatherData implements Observerable {

	private float temp;
	private float humidity;
	private float pressure;
	
	List<Observer>observers = new ArrayList<Observer>();
	public void registerObserver(Observer o) {
		observers.add(o);
	}

	public void removeObserver(Observer o) {
		if(observers.contains(o)){
			observers.remove(o);
		}
	}

	public void notifyObservers() {
		for(Observer o:observers){
			o.update(temp, humidity, pressure);
		}
	}
	
	public void setMeasurements(float temp,float humidity,float pressure){
		this.temp = temp;
		this.humidity = humidity;
		this.pressure = pressure;
		mesurementsChanged();
	}
	
	public void mesurementsChanged(){
		notifyObservers();
	}

}
